package com.petc.channel.service.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        //单机模式
        config.useSingleServer()
                .setAddress("redis://115.190.8.244:16379")
                .setPassword("Xht2025@redis")
                .setConnectionPoolSize(64)
                .setIdleConnectionTimeout(10000);
        //集群模式
        /*config.useClusterServers()
                .addNodeAddress("redis://node1:6379", "redis://node2:6380")
                .setScanInterval(2000);  // 集群节点扫描间隔（毫秒）:ml-citation{ref="3,5" data="citationList"}*/

        //哨兵模式
        /*config.useSentinelServers()
                .setMasterName("mymaster")  // 主节点名称
                .addSentinelAddress("redis://sentinel1:26379", "redis://sentinel2:26380"):ml-citation{ref="5,8" data="citationList"};*/

        return Redisson.create(config);
    }
}

